<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="./029深拷贝.js"></script>
    <script>
        const obj={
            a:1,
            b:['e','f','g'],
            c:{h:20},
            //JSON不能克隆方法
            d:function(){}
        }

        //循环引用的时候 报错
        /* obj.b.push(obj.c);
        obj.c.j=obj.b; */

        const result=deepClone1(obj)
        result.c.h=30
        console.log(result);
        console.log(obj);


        const result2=deepClone2(obj)
        console.log(result2);
    </script>
</body>
</html>